<template>
	<view>
		<view class="main">
      <Home v-if="tabName === 0"></Home>
      <Mine v-if="tabName === 1"></Mine>
    </view>
    <!--tab-->
    <u-tabbar
        :value="tabName"
        @change="name => tabName = name"
        :fixed="true"
        :placeholder="true"
        :safeAreaInsetBottom="true"
    >
      <u-tabbar-item text="首页" icon="home" value="home"></u-tabbar-item>
      <!--<u-tabbar-item text="物料" icon="photo" ></u-tabbar-item>-->
      <u-tabbar-item text="我的" icon="account" value="mine"></u-tabbar-item>
    </u-tabbar>
	</view>
</template>

<script>
  import Home from './home/index.vue'
  import Mine from './mine/index.vue'
	export default {
    components: {
      Home,
      Mine
    },
		data() {
			return {
				tabName: 0,
        tabComponent: {
          home: Home,
          material: 'material',
          mine: Mine
        }
			}
		},
		methods: {
      toLogin(){
        uni.navigateTo({
          url: '/pages/login/index'
        })
      }
		},
    created() {
      // this.toLogin()
      uni.request({
        url: "http://47.96.95.233:8081/dev-api/applet/getHomeStatistics",
        method: "GET",
        header: {
          Authorization: "eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6Ijk3OGUyYWYwLTY2MGUtNDg2Yy1hMmY4LWQwM2E1OTVkMGIzZCJ9.TRM4Z06DQwMtNwk8HweN7rzVUFMiLgaQXbMa2Lv9mI5_-P6L12gHnOC4ZHVRCWt--bJgIwLxtpP25W9mpn0HXg"
        },
      })
    }
	}
</script>

<style>
	.main {
    padding: 10px;
  }
</style>
